import { Button } from "antd";

export const gradeTableColumn = (updateGrade,delectGrade) =>{

 const studentColumn = [
  {
    title: '序号',
    dataIndex: 'index',
    key: 'index',
    align: 'center',
    render: (text, record, index) => {
      return text;
    },
  },
  {
    title: '学期',
    dataIndex: 'fd_semester',
    key: 'fd_semester',
    align: 'center',
    render: (text, record, index) => {
      if (text === 1) return "大一上"
      if (text === 2) return "大一下"
      if (text === 3) return "大二上"
      if (text === 4) return "大二下"
      if (text === 5) return "大三上"
      if (text === 6) return "大三下"
      if (text === 7) return "大四上"
      if (text === 8) return "大四下"
    },
  },
  {
    title: '课程',
    dataIndex: 'fd_curriculumName',
    key: 'fd_curriculumNum',
    align: 'center',
  },
  {
    title: '课程编号',
    dataIndex: 'fd_curriculumNum',
    key: 'fd_curriculumNum',
    align: 'center',
  },
  {
    title: '考核分',
    dataIndex: 'fd_assessmentScore',
    key: 'fd_assessmentScore',
    align: 'center',
  },
  {
    title: '平时分',
    dataIndex: 'fd_gradeInCourseWork',
    key: 'fd_gradeInCourseWork',
    align: 'center',
  },
  {
    title: '综合分',
    dataIndex: 'fd_comprehensiveScore',
    key: 'fd_comprehensiveScore',
    align: 'center',
  },
  {
    title: '任课老师',
    dataIndex: 'fd_name',
    key: 'fd_name',
    align: 'center',
  },
];

const teacherColumn = [
  {
    title: '序号',
    dataIndex: 'index',
    key: 'index',
    align: 'center',
    render: (text, record, index) => {
      return text;
    },
  },
  {
    title: '班级',
    dataIndex: 'fd_claName',
    key: 'fd_claName',
    align: 'center',
  },
  {
    title: '课程',
    dataIndex: 'fd_curriculumName',
    key: 'fd_curriculumNum',
    align: 'center',
  },
  {
    title: '课程编号',
    dataIndex: 'fd_curriculumNum',
    key: 'fd_curriculumNum',
    align: 'center',
  },
  {
    title: '考核分',
    dataIndex: 'fd_assessmentScore',
    key: 'fd_assessmentScore',
    align: 'center',
  },
  {
    title: '平时分',
    dataIndex: 'fd_gradeInCourseWork',
    key: 'fd_gradeInCourseWork',
    align: 'center',
  },
  {
    title: '综合分',
    dataIndex: 'fd_comprehensiveScore',
    key: 'fd_comprehensiveScore',
    align: 'center',
  },
  {
    title: '学生',
    dataIndex: 'fd_name',
    key: 'fd_name',
    align: 'center',
  },
  {
    title: '学号',
    dataIndex: 'fd_studNum',
    key: 'fd_studNum',
    align: 'center',
  },
  {
    title: '操作',
    dataIndex: 'operation',
    width:124,
    align: 'center',
    render: (_, record) => {
      return (
        <>
          <Button onClick={() => updateGrade(record)} size='small'  >修改</Button>
          <Button onClick={() => delectGrade(record)} size='small'  >删除</Button>
        </>
      )
    }
  }
]

  return {studentColumn,teacherColumn}
}

export const searchColList =(options)=>{
  const{classes,curriculum} = options

  const semesterOptions = [
    { value: '', label: '学期', },
    { value: "1", label: "大一上" },
    { value: "2", label: "大一下" },
    { value: "3", label: "大二上" },
    { value: "4", label: "大二下" },
    { value: "5", label: "大三上" },
    { value: "6", label: "大三下" },
    { value: "7", label: "大四上" },
    { value: "8", label: "大四下" },
  ]

  const studentColList = [
    { span: 5, offset: 0, name: "fd_semester", label: "学期", semesterOptions },
    { span: 5, offset: 1, name: "fd_comprehensiveScore", label: "综合分",  },
    { span: 5, offset: 1, name: "fd_name", label: "任课老师",  },
    { span: 5, offset: 1, name: "fd_type", label: "课程类别",  },
    { span: 5, offset: 0, name: "fd_curriculumName", label: "课程" },
  ]
  const teacherColList = [
    { span: 5, offset: 0, name: "fd_claNum", label: "班级", rules:{required: true,message: '请选择需要查询的班级',},classes},
    { span: 5, offset: 0, name: "fd_name", label: "学生", },
    { span: 5, offset: 0, name: "fd_curriculumNum", label: "课程",rules:{required: true,message: '请输入需要查询的课程',},curriculum },
  ]

  return {studentColList,teacherColList}
}